package com.demo.controller.front;

import com.demo.common.model.Article;
import com.jfinal.core.Controller;

public class ArticleController extends Controller{
	public void index(){
		Article article = Article.me.findById(getParaToInt());
		
		setAttr("article", article);
		setAttr("tags", Article.me.getTags(article));
		setAttr("prev_at", Article.me.prev(article.get("id").toString()));
		setAttr("next_at",  Article.me.next(article.get("id").toString()));
		article.set("read_count",Integer.parseInt(article.get("read_count").toString())+1).update();
		render("/article.html");
	}
	public void getById(){
		Article article = Article.me.findById(getParaToInt());
		setAttr("article", article);
		setAttr("tags", Article.me.getTags(article));
		render("/article.html");
	}

}
